home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 97 / CD-ROM 97 / CD-ROM 97.iso / internet / ghostzilla / ghsetup.exe / chrome / chatzilla.jar / content / chatzilla / lib / js / irc-debug.js < prev    next >
Encoding:
JavaScript  |  2002-04-09  |  3.0 KB  |  104 lines

  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2.  *   
  3.  * The contents of this file are subject to the Mozilla Public
  4.  * License Version 1.1 (the "License"); you may not use this file
  5.  * except in compliance with the License. You may obtain a copy of
  6.  * the License at http://www.mozilla.org/MPL/
  7.  *
  8.  * Software distributed under the License is distributed on an "AS
  9.  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  10.  * implied. See the License for the specific language governing
  11.  * rights and limitations under the License.
  12.  *
  13.  * The Original Code is JSIRC Library
  14.  *
  15.  * The Initial Developer of the Original Code is New Dimensions Consulting,
  16.  * Inc. Portions created by New Dimensions Consulting, Inc. are
  17.  * Copyright (C) 1999 New Dimenstions Consulting, Inc. All
  18.  * Rights Reserved.
  19.  *
  20.  * Contributor(s):
  21.  *  Robert Ginda, rginda@ndcico.com, original author
  22.  */
  23.  
  24. /*
  25.  * Hook used to trace events.
  26.  */
  27. function event_tracer (e)
  28. {
  29.     var name = "";
  30.     var data = ("debug" in e) ? e.debug : "";
  31.     
  32.     switch (e.set)
  33.     {
  34.         case "server":
  35.             name = e.destObject.connection.host;
  36.             if (e.type == "rawdata")
  37.                 data = "'" + e.data + "'";
  38.             if (e.type == "senddata")
  39.             {
  40.                 var nextLine =
  41.                     e.destObject.sendQueue[e.destObject.sendQueue.length - 1];
  42.                 if ("logged" in nextLine)
  43.                     return true; /* don't print again */
  44.                 
  45.                 if (nextLine) {
  46.                     data = "'" + nextLine.replace ("\n", "\\n") + "'";
  47.                     nextLine.logged = true;
  48.                 }
  49.                 else
  50.                     data = "!!! Nothing to send !!!";                
  51.             }
  52.             break;
  53.  
  54.         case "network":
  55.         case "channel":
  56.             name = e.destObject.name;
  57.             break;
  58.  
  59.         case "user":
  60.             name = e.destObject.nick;
  61.             break;
  62.  
  63.         case "httpdoc":
  64.             name = e.destObject.server + e.destObject.path;
  65.             if (e.destObject.state != "complete")
  66.                 data = "state: '" + e.destObject.state + "', received " +
  67.                     e.destObject.data.length;
  68.             else
  69.                 dd ("document done:\n" + dumpObjectTree (this));
  70.             break;
  71.  
  72.         case "dcc-chat":
  73.             name = e.destObject.host + ":" + e.destObject.port;
  74.             if (e.type == "rawdata")
  75.                 data = "'" + e.data + "'";
  76.             break;
  77.  
  78.         case "client":
  79.             if (e.type == "do-connect")
  80.                 data = "attempt: " + e.attempt + "/" +
  81.                     e.destObject.MAX_CONNECT_ATTEMPTS;
  82.             break;
  83.  
  84.         default:
  85.             break;
  86.     }
  87.  
  88.     if (name)
  89.         name = "[" + name + "]";
  90.  
  91.     if (e.type == "info")
  92.         data = "'" + e.msg + "'";
  93.     
  94.     var str = "Level " + e.level + ": '" + e.type + "', " +
  95.         e.set + name + "." + e.destMethod;
  96.     if (data)
  97.       str += "\ndata   : " + data;
  98.  
  99.     dd (str);
  100.  
  101.     return true;
  102.  
  103. }
  104.